// Copyright (C) 1995.  This code is governed by the MiscKit license.

#import <remote/NXConnection.h>

main()
{
	id server;
	id docList;
	int count;
	id 
		obj,
		cell,
		parser;
	char
		*t;
	
	server = [NXConnection connectToName:"IBMole"];
	if (server)
	{
		printf("Got the mole!\n");
	}
	docList = [server docList];
	count = [docList count];
	printf("%d docs\n",count);
	while (count--)
	{
		int objCount;
		id objs=[[List alloc] init];
		
		[[docList objectAt:count] getObjects:objs];
		objCount = [objs count];
	printf("%d objects\n",objCount);
		while (objCount--)
		{
			cell = nil;
			obj = [objs objectAt:objCount];
			
			if ([obj respondsTo:@selector(stringValue)] &&
				[obj respondsTo:@selector(setStringValue:)])
			{
			printf(".");
				t = [obj stringValue];
				if (t && (!strcmp("Cost per Share",t)))
				{
					[obj setStringValue:"Cost per Unit"];
					[[docList objectAt:count] redrawObject:obj];
					[[docList objectAt:count] touch];
					printf("Changed one!\n");
				}
			}

			if ([obj respondsTo:@selector(title)] &&
				[obj respondsTo:@selector(setTitle:)])
			{
			printf(".");
				t = [obj title];
				if (t && (!strcmp("Entity",t)))
				{
					[obj setTitle:"Account"];
					[[docList objectAt:count] redrawObject:obj];
					[[docList objectAt:count] touch];
					printf("Changed one!\n");
				}
				else if (t && (!strcmp("Account",t)))
				{
					[obj setTitle:"Subaccount"];
					[[docList objectAt:count] redrawObject:obj];
					[[docList objectAt:count] touch];
					printf("Changed one!\n");
				}
				else if (t && (!strcmp("Ledger Acct",t)))
				{
					[obj setTitle:"Ledger Name"];
					[[docList objectAt:count] redrawObject:obj];
					[[docList objectAt:count] touch];
					printf("Changed one!\n");
				}
				else if (t && (!strcmp("Ledger Account",t)))
				{
					[obj setTitle:"Ledger Name"];
					[[docList objectAt:count] redrawObject:obj];
					[[docList objectAt:count] touch];
					printf("Changed one!\n");
				}
			}

			if ([obj respondsTo:@selector(keyEquivalent)] &&
				[obj respondsTo:@selector(setKeyEquivalent:)])
			{
			printf(".");
				if ([obj keyEquivalent] == 'R')
				{
					[obj setKeyEquivalent:'V'];
					[[docList objectAt:count] redrawObject:obj];
					[[docList objectAt:count] touch];
					printf("Changed R to V!\n");
				}
			}


		}
	}
	exit(0);
}
